<?php
// 登录控制器
class LoginController extends CommonController{
    // 登陆异步
	public function login(){	
		// if($_SESSION['username']){
		// 	$this->error('用户已登录');
		// }
		$name=Q('post.username');
		$password=md5(Q('post.password'));
		$name_all=K('User')->get_data(array('username'=>$name));

		if (empty($name_all)) {
			$this->error('用户不存在');  
		}else{
			$name_all=current($name_all);
			if ($name==$name_all['username'] && $password==$name_all['password']) {
                // echo $name;
                $_SESSION['username']=$name;
                $_SESSION['uid']=$name_all['uid']; 
			}
		}		
	}
    // 退出
	public function out(){
		session(NULL);
        $this->success('退出成功');
	} 
}
